<!-- 代理、商务和店长申请中心  -->
<template>
	<s-layout navbar="inner" class="index-wrap" :title="title" :bgStyle="bgStyle" :onShareAppMessage="shareInfo"
		v-if="detailData.isApply">
		<!-- 分销商信息 -->
		<commission-info :detailData="detailData" />
		<!-- 账户信息 -->
		<account-info :detailData="detailData" />
		<!-- 经营数据 -->
		<commission-operate :detailData="detailData" />
		<!-- 积分数据 -->
		<commission-points :detailData="detailData" />
		<!--  锁客数据-->
		<commission-customer :detailData="detailData" />
		<!-- 权限弹窗 -->
		<commission-auth />
	</s-layout>
	<s-layout class="index-wrap" :title="title" v-else>
		<view class="empty-box">
			<uni-icons type="shop" size="60"></uni-icons>
			您还不是商户，请联系管理员！
		</view>
	</s-layout>
</template>

<script setup>
	import {
		computed,
		onMounted,
		reactive,
		ref
	} from 'vue';
	import {
		onLoad
	} from '@dcloudio/uni-app';
	import commissionInfo from './components/commission-info.vue';
	import accountInfo from './components/account-info.vue';
	import commissionAuth from './components/commission-auth.vue';
	import commissionOperate from './components/commission-operate.vue';
	import commissionPoints from './components/commission-points.vue';
	import commissionCustomer from './components/commission-customer.vue';
	import sheep from '@/sheep';
	import {
		SharePageEnum,
		getBrokerageTitleEnum,
		BrokerageTypeEnum
	} from '@/sheep/util/const';

	import BrokerageApi from '@/sheep/api/trade/brokerage';

	const title = ref('')
	const detailData = ref('')

	/** 分销邀请 */
	const shareInfo = computed(() => {
		return sheep.$platform.share.getShareInfo({
			params: {
				page: SharePageEnum.HOME.value, // 用户通邀请进入到首页
			},
		}, {
			type: 'user',
		});
	});

	// 获得代理申请数据
	const getBrokerageInfo = () => {
		BrokerageApi.getBrokerageUserApplyInfo({
			applyType: BrokerageTypeEnum.DZ.type,
		}).then((res) => {
			if (res.code === 0) {
				detailData.value = {
					...res.data,
					type: BrokerageTypeEnum.DZ.type
				}
			}
		})
	};

	const bgStyle = {
		color: '#F7D598',
	};

	onLoad((val) => {
		if (val.type == '3') {
			title.value = '商户端'
		}
		getBrokerageInfo()
	})
</script>

<style lang="scss" scoped>
	:deep(.page-main) {
		background-size: 100% 100% !important;
	}

	.empty-box {
		height: 80vh;
		display: flex;
		flex-direction: column;
		gap: 10rpx;
		justify-content: center;
		align-items: center;
		color: #555;
	}
</style>